Using the data whately 2015 from the macleish package, create an interac- tive plot using plotly (or ggplotly) displaying time (in days) on the x-axis and temperature on the y-axis with three lines: one for the high temper- ature of the day, one for the average temperature of the day, and one for the low temperature of the day. A csv version of the file can be found here: https://www.dropbox.com/s/m2nt50qanpijp0m/whately2015.csv?dl=0

library(mdsr)
library(macleish)
## Loading required package: etl
## Loading required package: dplyr
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(lubridate)
## 
## Attaching package: 'lubridate'
## The following objects are masked from 'package:base':
## 
##     date, intersect, setdiff, union
library(plotly) 
## Loading required package: ggplot2
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ forcats 1.0.0     ✔ stringr 1.5.0
## ✔ purrr   1.0.2     ✔ tibble  3.2.1
## ✔ readr   2.1.4     ✔ tidyr   1.3.0
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ plotly::filter() masks dplyr::filter(), stats::filter()
## ✖ dplyr::lag()     masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
whately <- whately_2015

#convert when to date object
whately$weather_date <- as.Date(whately$when)

#add column for day of the year and calculate temperature measures for each day
whately <- whately %>% mutate(day_of_year = yday(weather_date)) %>% group_by(day_of_year) %>% summarize(high_temp=max(temperature), low_temp=min(temperature), ave_temp=ave(temperature))
## Warning: Returning more (or less) than 1 row per `summarise()` group was deprecated in
## dplyr 1.1.0.
## ℹ Please use `reframe()` instead.
## ℹ When switching from `summarise()` to `reframe()`, remember that `reframe()`
##   always returns an ungrouped data frame and adjust accordingly.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
## `summarise()` has grouped output by 'day_of_year'. You can override using the
## `.groups` argument.
whately
## # A tibble: 52,560 × 4
## # Groups:   day_of_year [365]
##    day_of_year high_temp low_temp ave_temp
##          <dbl>     <dbl>    <dbl>    <dbl>
##  1           1    -0.334    -10.1    -5.36
##  2           1    -0.334    -10.1    -5.36
##  3           1    -0.334    -10.1    -5.36
##  4           1    -0.334    -10.1    -5.36
##  5           1    -0.334    -10.1    -5.36
##  6           1    -0.334    -10.1    -5.36
##  7           1    -0.334    -10.1    -5.36
##  8           1    -0.334    -10.1    -5.36
##  9           1    -0.334    -10.1    -5.36
## 10           1    -0.334    -10.1    -5.36
## # ℹ 52,550 more rows
#create plot with line for each measure
g <- ggplot(aes(x = day_of_year), data = whately)+
  geom_line(aes(y = high_temp, color = "High"))+
  geom_line(aes(y = low_temp, color = "Low"))+
  geom_line(aes(y = ave_temp, color = "Ave"))+
  xlab("Day of Year")+
  ylab("Temperature")+
  labs(title ="Temperatures through the Year",
       color = "Temperature Measures")

#make plot interactive
ggplotly(g)

Python version: https://colab.research.google.com/drive/1AFCz7vT15EiZATUsE-1ajxn4veN7nMOb?usp=sharing